package com.omronservice.app.curve.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;


@RestController
@RequestMapping("/test")
public class TestController {


    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    //@Autowired
    //private RedisTemplate<String, Object> redisTemplate;
    @RequestMapping("/save")
    public String save(){
        stringRedisTemplate.opsForValue().set("name", "guanguan");
        String val =  stringRedisTemplate.opsForValue().get("myKey");
        String name =  stringRedisTemplate.opsForValue().get("name");
        stringRedisTemplate.opsForList().rightPush("listt","listt1");
        stringRedisTemplate.opsForList().rightPush("listt","listt2");
        stringRedisTemplate.opsForList().rightPush("listt","listt3");
        List listt = Collections.singletonList(stringRedisTemplate.opsForList().rightPop("listt"));
        Long listsize =stringRedisTemplate.opsForList().size("listt");
        return name+"---save ok-----"+val+"-"+listsize+"---"+listt;
    }

}
